package com.example.siyun.controller.permissionscontroller;

import com.example.siyun.pojo.CustomerManage;
import com.example.siyun.pojo.EnumPojo;
import com.example.siyun.pojo.FeedBackList;
import com.example.siyun.service.permissionsservice.CustomerManageService;
import com.example.siyun.util.PageResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @Auther: 全
 * @Date: 2022/9/26 09:33
 * @Description:权限管理模块客服管理
 */
@Slf4j
@RestController
public class CustomerManageController {
    @Autowired
    private CustomerManageService customerManageService;
    /**
     * 获取客服管理的数据
     * @return 返回客服管理的数据
     */
    @RequestMapping("/advanced/getcustomermanage")
    public PageResult getCustomerManage(CustomerManage customerManage,int page, int limit) {
        log.info("获取客服管理的数据");
        PageHelper.startPage(page, limit);
        List<CustomerManage> list = customerManageService.getCustomerManage(customerManage, EnumPojo.VALUE_DEL_0);
        PageInfo<CustomerManage> pageInfo = new PageInfo<>(list);
        PageResult pageResult=new PageResult();
        pageResult.setState(0);
        pageResult.setMessage("成功");
        pageResult.setTotal(pageInfo.getTotal());
        pageResult.setData(pageInfo.getList());
        log.info("获取客服管理的数据");
        return pageResult;
    }
    @RequestMapping("/advanced/selectcustheader")
    public Map<String, Object> selectAllHeader() {
        Map<String, Object> selectdata = customerManageService.selectCustomerHeader();
        return selectdata;
    }
    /**
     * 通过id获取客服管理信息
     * @return 返回客服管理信息
     */
    @RequestMapping("/advanced/selectcustomerbyid")
    public PageResult selectFeedBackById(int id){
        log.info("通过id获取客服管理信息");
        Map<String, Object> map = new HashMap<>();
        CustomerManage customerManage= customerManageService.getC(id);
        PageResult pageResult=new PageResult();
        pageResult.setData(customerManage);
        log.info("通过id获取客服管理信息成功");
        return pageResult;
    }
    /**
     * 通过id删除对应的客服管理信息
     * @param  id 要删除的客服管理信息id
     */
    @RequestMapping("/advanced/delcustomerbyid")
    public PageResult delCourseTable(int id){
        log.info("通过id删除对应的客服管理信息");
        customerManageService.delcustomerbyid(id);
        PageResult pageResult=new PageResult();
//        pageResult.setStatus(200);
        log.info("通过id删除对应的客服管理信息成功");
        return pageResult;
    }
}
